using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using eShop.Business;
using ECommerce.Library;

public partial class admin_add_subscriber : SiteAdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        ddlNewsletterGroup.DataSource = NewsletterGroup.GetAllActiveGroups();
        ddlNewsletterGroup.DataBind();
    }

    protected void Create_Click(object sende, EventArgs e)
    {
        if (IsValid)
        {
            try
            {
                NewsletterSubscriber newSubscriber = new NewsletterSubscriber(0, tbxSubscriberName.Text, tbxSubscriberEmail.Text, Convert.ToInt32(ddlNewsletterGroup.SelectedValue));
                newSubscriber.Update();
                uccResponseMessage.SetSuccessMessage("Subscriber successfuly created");
            }
            catch (Exception ex)
            {
                uccResponseMessage.SetSuccessMessage("Failed to create subscriber");
            }
        }
    }
}
